net/mwan3: add lock for mwan3 hotplug script
authorFlorian Eckert <[email protected]>
Thu, 22 Jun 2017 09:48:01 +0000 (11:48 +0200)
committerFlorian Eckert <[email protected]>
Thu, 22 Jun 2017 11:42:12 +0000 (13:42 +0200)
If more then one interface get up/down at once mwan3 could be in a
undefined state, because more then one mwan3 hotplug script are running
and editing the iptables.

Lock the critical section should solve this issue.

Signed-off-by: Florian Eckert <[email protected]>
net/mwan3/files/etc/hotplug.d/iface/15-mwan3
net/mwan3/files/lib/mwan3/mwan3.sh

index e3fd16cef0f27f492bb78f288e4ffdc9ef23f078..ca8f24daf912d631913626cb53649223cbc61f82 100644 (file)
@@ -38,6 +38,7 @@ if [ "$ACTION" == "ifup" ]; then
        [ -n "$gateway" ] || exit 9
 fi
 
+mwan3_lock
 $LOG notice "$ACTION interface $INTERFACE (${DEVICE:-unknown})"
 
 case "$ACTION" in
@@ -64,4 +65,6 @@ case "$ACTION" in
        ;;
 esac
 
+mwan3_unlock
+
 exit 0
index 3798d7eb055c00e4d09a8497bdc8bcbe8618d68d..f4c55a96ec8da1e6d862509d3afb9e0e77c7e84a 100644 (file)
@@ -8,6 +8,14 @@ IPT6="ip6tables -t mangle -w"
 LOG="logger -t mwan3 -p"
 CONNTRACK_FILE="/proc/net/nf_conntrack"
 
+mwan3_lock() {
+       lock /var/run/mwan3.lock
+}
+
+mwan3_unlock() {
+       lock -u /var/run/mwan3.lock
+}
+
 mwan3_get_iface_id()
 {
        local _tmp _iface _iface_count